package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmLoginDto;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.model.wemedia.pojos.WmMaterial;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {


    @Autowired
    WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(@RequestParam("multipartFile") MultipartFile file){
        return wmMaterialService.uploadPicture(file);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto){
        return wmMaterialService.findAll(dto);
    }


    @GetMapping("collect/{id}")
    public ResponseResult collect(@PathVariable("id") String id){
        return wmMaterialService.collect(id);
    }

    @GetMapping("cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable("id") String id){
        return wmMaterialService.collect(id);
    }


    @GetMapping("/del_picture/{id}")
    public ResponseResult delPicture(@PathVariable("id") String id){
        return wmMaterialService.delPicture(id);
    }

}
